
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>JPA与数据库设计 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>JPA与数据库设计 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">JPA的核心思想是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">JPA的核心思想是对象关系映射（ORM），即通过Java实体类（Entity）来操作数据库表，从而避免了繁琐的SQL操作。</div>
          </div>
          <div class="card-source">来源: 一、JPA与数据库设计的关系</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">JPA为实体类的继承关系提供了哪三种映射策略？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">JPA为继承关系提供了三种映射策略：1. 单表继承（Single Table）；2. 联合表继承（Joined Table）；3. 表独立继承（Table Per Class）。</div>
          </div>
          <div class="card-source">来源: 2.2 继承映射</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在JPA的“单表继承”（Single Table）策略中，如何区分同一个表中的数据属于哪个子类实体？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在“单表继承”策略中，通过一个“discriminator column”（区分列）来标识每一行数据所属的具体实体类型。</div>
          </div>
          <div class="card-source">来源: 1. 单表继承（Single Table）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">在JPA一对多（One-To-Many）关系映射中，`mappedBy`属性的作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`mappedBy`属性用于指定关系维护方。例如在订单和订单项的关系中，`mappedBy = "order"`表示外键关系由OrderItem实体（“多”的一方）来维护，这样可以避免在Order表（“一”的一方）中创建额外的关联列。</div>
          </div>
          <div class="card-source">来源: 3.2 一对多（One-To-Many）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">JPA是如何在数据库层面实现多对多（Many-To-Many）关系的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">JPA通过创建一个中间表（Join Table）来实现多对多关系。这个中间表会存储两个关联实体的主键作为外键，以记录它们之间的对应关系。</div>
          </div>
          <div class="card-source">来源: 3.3 多对多（Many-To-Many）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">在JPA中，`fetch = FetchType.LAZY`配置（懒加载）有什么好处？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">懒加载（Lazy Loading）可以提高性能。它使得关联的实体或集合只有在被实际访问时才会被加载，从而避免了不必要的数据查询和加载。</div>
          </div>
          <div class="card-source">来源: 3.2 一对多（One-To-Many）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">“联合表继承”（Joined Table）策略相比“单表继承”策略，其优缺点分别是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">优点是数据更规范，避免了数据冗余和过多的空值。缺点是查询时需要进行JOIN操作，导致查询性能相对较低。</div>
          </div>
          <div class="card-source">来源: 2. 联合表继承（Joined Table）</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">文档中提到了哪些用于提升JPA应用性能的数据库优化策略？请列举至少三项。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到的优化策略包括：1. 索引优化：为频繁查询的字段添加索引。2. 懒加载（Lazy Loading）：避免不必要的数据加载。3. 批量操作：使用`@BatchSize`或`JOIN FETCH`避免N+1查询问题。4. 事务控制。5. 缓存机制。</div>
          </div>
          <div class="card-source">来源: 四、数据库优化策略</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在JPA中，`@GeneratedValue(strategy = GenerationType.IDENTITY)`注解的作用是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该注解用于指定主键的生成策略。`GenerationType.IDENTITY`表示主键的生成工作委托给数据库的自增（auto-increment）机制来完成。</div>
          </div>
          <div class="card-source">来源: 2.1 单表映射</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
